package signRecord

import (
	"api/internal/svc"
	"api/internal/types"
	"context"
	"user_srv/userclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type IsBitmapSignedLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewIsBitmapSignedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IsBitmapSignedLogic {
	return &IsBitmapSignedLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *IsBitmapSignedLogic) IsBitmapSigned(req *types.IsBitmapSigned) (resp *types.Response, err error) {
	signed, err := l.svcCtx.UserRpc.IsBitmapSigned(l.ctx, &userclient.IsBitmapSignedRequest{ //判断是否签到
		UserId: int64(req.UserId),
	})
	if err != nil {
		return &types.Response{
			Code:    400,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Code:    200,
		Message: "查询成功",
		Data:    signed.Signed,
	}, nil
}
